<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>柱状图</title>
</head>
<body>
  <!-- 2.创建dom -->
  <div id="main" style="width: 800px; height: 400px"></div>
  <!-- 1.引入 -->
  <script src="./lib/echarts.min.js"></script>
  
  <script>
    // 3.实例化echarts
    const myChart = echarts.init(document.getElementById('main'))
    // 4.复制echarts结构
    const option = {
  title: {
    text: '2022全学科薪资走势',
    top: '2%',
    left: '3%'
  },
  // 图表
  grid: {
    // 设置上下左右的间隙
    top: '15%',
    left: '10%',
    right: '10%',
    bottom: '10%'
  },
  xAxis: {
    type: 'category',
    data: ['January', 'Febrary', 'March', 'April', 'May', 'June', 'July', 
    'August'],
    // 线段设置
    axisLine: {
      // 线的样式
      lineStyle: {
        type: 'dashed',
        color: '#333'
      }
    },
    axisLabel:{
      show: true,
      color: 'red'
    }
  },
  yAxis: {
    type: 'value',
    splitLine: {
      // 线的样式
      lineStyle: {
        type: 'dashed',
        color: '#d4d4d6'
      }
    }
  },
  color: [
    {
     type: 'linear',
     x: 0,
     y: 0,
     x2: 0,
     y2: 1,
     colorStops: [{
      offset: 0, color: 'skyblue' // 0% 处的颜色
     }, {
      offset: 1, color: 'pink' // 100% 处的颜色
     }],
    global: false // 缺省为 false
    },
    // 径向渐变，前三个参数分别是圆心 x, y 和半径，取值同线性渐变
   {
    type: 'radial',
    x: 0.5,
    y: 0.5,
    r: 0.5,
    colorStops: [{
      offset: 0, color: 'white' // 0% 处的颜色
    }, {
      offset: 1, color: 'wheat' // 100% 处的颜色
    }],
    global: false // 缺省为 false
   }
  ],
  series: [
    {
      data: [12000, 19000, 15000, 8000, 7000, 11000, 13000, 17500],
      type: 'bar',
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(180, 180, 180, 0.2)'
      }
    },
     {
      data: [14000, 20000, 16000, 9000, 7500, 11000, 12000, 13500],
      type: 'bar',
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(180, 180, 180, 0.2)'
      }
    }
  ]
};
    // 5.将结构给实例化对象
    myChart.setOption(option)
  </script>
</body>
</html>